<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
        .upLoadFormDadaDiv{
            position: relative;
            cursor: pointer;
        }
        .upLoadFormDadaDiv #AjaxFileData{
            position: absolute;
            top: 0;left: 0;
            opacity: 0;
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <input type="hidden" name="billCode">


    <div class="layui-form-item bh-item">
        <label class="layui-form-label required">发票预警额度</label>
        <div class="layui-input-block">
            <input type="number" name="invoiceMoney" lay-verify="required" lay-reqtext="请输入预警发票额度" placeholder="请输入预警发票额度" value="" class="layui-input">

        </div>
    </div>
    
        <div class="layui-form-item bh-item">
        <label class="layui-form-label required">发票预警张数</label>
        <div class="layui-input-block">
            <input type="number" name="invoiceSum" lay-verify="required" lay-reqtext="请输入发票预警张数" placeholder="请输入发票预警张数" value="" class="layui-input">

        </div>
    </div>
    
        <div class="layui-form-item bh-item">
        <label class="layui-form-label required">提示邮箱</label>
        <div class="layui-input-block">
            <input type="text" name="invoiceMail" lay-verify="required" lay-reqtext="请输入企业邮箱" placeholder="请输入企业邮箱" value="" class="layui-input">

        </div>
    </div>
    
    


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form','upload','tfApi'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$,
            API = layui.tfApi;
        
        
        $.post(API.CURL + '/service/findByInvocer' , {}, function (data) {
        	var res = JSON.parse(data);
        	if(res.data == null){
        		//console.log("无数据")
        	}else{
        		$("input[name='invoiceMoney']").val(res.data.invoiceMoney);
                $("input[name='invoiceMail']").val(res.data.datadicValue);
        		$("input[name='invoiceSum']").val(res.data.invoiceSum);
        	}
        })



        //监听提交
        form.on('submit(saveBtn)', function (data) {

            var invoiceMoney = $("input[name='invoiceMoney']").val(),
            invoiceMail = $("input[name='invoiceMail']").val(),
            invoiceSum = $("input[name='invoiceSum']").val(),
                formData = new FormData();

            $.ajax({
                url: API.CURL + '/service/updateInvoice?invoiceMoney='+invoiceMoney +"&invoiceMail=" + invoiceMail + "&invoiceSum="+invoiceSum,
                type: 'post',
               // data: formData,
                processData: false,
                contentType: false,
                success: function (res) {
                    console.log("ok=="+res);
                    var data = JSON.parse(res);
                    if(data.code == 0){
                        var index = layer.alert(data.msg, {
                            title: '最终的提交信息'
                        }, function () {

                            // 关闭弹出层
                            layer.close(index);
                            parent.location.reload();

                        });
                    }
                }
            });

            return false;
        });
        
        
        
        
    });
</script>
</body>
</html>